package rt

import (
	"fmt"
	"strconv"
	"kumachan/interpreter/lang/common/name"
)

type MaybeSymbol interface{ MaybeSymbol() }
func (Symbol) MaybeSymbol() {}
type Symbol struct {
	Namespace  string
	Item       string
	Tag        string
}
func MakeSymbol(mod string, item string) Symbol {
	return Symbol {
		Namespace: mod,
		Item:      item,
	}
}
func MakeSymbol3(mod string, item string, tag string) Symbol {
	return Symbol {
		Namespace: mod,
		Item:      item,
		Tag:       tag,
	}
}
func SymbolFromTypeName(n name.TypeName) Symbol {
	return MakeSymbol(n.ModuleName, n.ItemName)
}
func SymbolFromFunctionName(n name.FunctionName) Symbol {
	return MakeSymbol3(n.ModuleName, n.ItemName, n.Tag)
}
func (sym Symbol) MessageString() string {
	return fmt.Sprintf("%s::%s(%s)", sym.Namespace, sym.Item, sym.Tag)
}
func (sym Symbol) String() string {
	return fmt.Sprintf (
		"%s::%s::%s",
		strconv.Quote(sym.Namespace),
		strconv.Quote(sym.Item),
		strconv.Quote(sym.Tag),
	)
}


